package model;

import java.io.*;
import view.ClientGUI;

/**
 * Klasse ConnectionRunnable
 * 
 * @author Magnus Brieler
 */
public class OutputRunnable implements Runnable {

	// Attribute
	private Packet packet;

	// Konstruktoren
	public OutputRunnable() {
		super();
		packet = new Packet();
	}

	public OutputRunnable(Packet packet) {
		super();
		this.packet = packet;
	}

	// Methoden
	@Override
	public void run() {
		try {
			controller.Client.oos.writeObject((Object) packet);
			if (!controller.Client.close) {
			}
		} catch (Exception ex) {
			if (!controller.Client.close) {
				view.ClientGUI.createError(ClientGUI.ErrorType.CONNECTION);
			}
		} finally {
			try {
				controller.Client.oos.flush();
			} catch (Exception ex) {
			}
		}
	}

}